package com.breeze.blockchain.socket.manager;

import com.breeze.blockchain.common.enums.RedisKeyEnum;
import com.breeze.components.socket.WebSocketManager;
import com.breeze.components.socket.redis.RedisWebSocketManager;
import com.breeze.components.socket.vo.WebSocketRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

/**
 * @author breeze
 */
@Component(WebSocketManager.WEBSOCKET_MANAGER_NAME)
@Slf4j
public class CustomRedisWebSocketManager extends RedisWebSocketManager {

  public CustomRedisWebSocketManager(StringRedisTemplate stringRedisTemplate) {
    super(stringRedisTemplate);
  }

  @Override
  public void onMessage(String identifier, WebSocketRequest request) {
    // 消息分发
    // if (StrUtil.isEmpty(identifier) || StrUtil.isEmpty(request.getCmd())) {
    //   return;
    // }
    // WebSocketCmd socketCmd = WebSocketCmd.fromCode(request.getCmd());
    // if (Objects.isNull(socketCmd)) {
    //   return;
    // }
    // WebSocketMsgService webSocketMsgService =
    //     getApplicationContext().getBean(WebSocketMsgService.class);
    // switch (socketCmd) {
    //
    // }
  }

  @Override
  protected String getCountKey() {
    return RedisKeyEnum.ONLINE_CLIENT_COUNT.getKey();
  }
}
